﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Xml.Linq;
using System.Data.Objects;

namespace WebTestLinq
{
    public partial class _Default : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            //SelectLinq();
            Bind();
        }

        private void Bind()
        {
            NorthwindEntities northE = new NorthwindEntities();
            GridView1.DataSource = from p in northE.Customers
                                   where p.City == "London" && p.Address == ""
                                   select p;
            GridView1.DataBind();
        }

        public static void SetXmlFunction()
        {
            XDocument d = new XDocument(
                new XDocument("This is a comment"),
                new XProcessingInstruction("xml-stylesheet","href='mystyle.css' title='Compact' type='text/css'"),
                new XElement("Pubs")
                );
        }

        public void SelectLinq()
        { 
            using (var edm = new NorthwindEntities())
            {
                ObjectQuery<Customer> customers = edm.Customers;
                IQueryable<Customer> cust1 = from c in customers
                                             select c;
                Response.Write(customers.ToTraceString());
            }
        }
    }
}
